<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <button onclick="seckill()">点击秒杀</button>
    <script src="jquery-3.3.1.js"></script>
    <script>
        function seckill() {
            var uid  = "";
            for (var i=0;i<5;i++){
                uid +=parseInt(10*Math.random());
            }

            $.ajax({
                url: "http://localhost:80/server/seckill",
                data: {
                    sid: "1001",
                    uid: uid
                },
                async: true,
                type: "POST",
                dataType: "json",
                contentType:"application/x-www-form-urlencoded",
                success: function(result){  //这个方法会在服务器执行成功是被调用 ，参数result就是服务器返回的值(现在是json类型)
                    if(result){
                        console.log(result);
                    }else{
                        console.log(result);
                    }
                }
            });

        }
    </script>
</body>
</html>